package com.momo.common.req.sysSetting.authority;

import com.momo.common.error.BaseReq;
import com.momo.mapper.dataobject.AclDO;
import lombok.*;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;


/**
 * Created by MOMO on 2019/3/21.
 */
@Getter
@Setter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
//@EqualsAndHashCode(of = {"id"})
public class AclReq extends BaseReq {
    /**
     * id 权限id.
     */
    private Long id;
    /**
     * sysAclModuleId 权限所在的权限模块id.
     */
    @NotNull(message = "权限所在的权限模块id 必填", groups = {Add.class, Modify.class})
    private Long sysAclModuleId;
    /**
     * sysAclPermissionType 菜单系统类型 1 系统管理 2资产管理.
     */
    @NotNull(message = "菜单系统类型 必填", groups = {Add.class, Modify.class})
    @Min(value = 1)
    private Long sysAclPermissionType;
    /**
     * name 页面名称(前端控制).
     */
//    @NotNull(message = "页面名称(前端控制) 必填", groups = {Add.class, Modify.class})
    private String name;
    /**
     * remark 备注.
     */
    private String remark;
    /**
     * delFlag 删除状态(0-正常，1-删除).
     */
    private String delFlag;
    /**
     * sysAclUrl 请求的url, 可以填正则表达式.
     */
    @NotBlank(message = "请求的url 必填", groups = {Add.class, Modify.class})
    private String sysAclUrl;
    /**
     * sysAclCode 权限码.
     */
    private String sysAclCode;
    /**
     * sysAclIcon 图标class.
     */
    private String sysAclIcon;
    /**
     * sysAclName 权限名称.
     */
    @NotNull(message = "权限名称 必填", groups = {Add.class, Modify.class})
    private String sysAclName;
    /**
     * sysAclType 类型，1：菜单，2：按钮，3：其他.
     */
    @NotBlank(message = "类型，1：菜单，2：按钮，3：其他 必填", groups = {Add.class, Modify.class})
    private String sysAclType;
    /**
     * sysAclUuid 唯一，32位字符串，查询用.
     */
    @NotBlank(message = "uuid 必填", groups = {Modify.class,Status.class,Detail.class})
    private String sysAclUuid;
    /**
     * sysAclAction 按钮动作类型(交给前端处理）.
     */
    @NotBlank(message = "按钮动作类型(交给前端处理） 必填", groups = {Add.class, Modify.class})
    private String sysAclAction;
    /**
     * sysAclRouter 所属页面(交给前端处理).
     */
    @NotBlank(message = "所属页面(交给前端处理)  必填", groups = {Add.class, Modify.class})
    private String sysAclRouter;
    /**
     * sysAclStatus 状态 0启用  1禁用.
     */
    @NotBlank(message = "状态 0启用  1禁用  必填", groups = {Add.class, Modify.class,Status.class})
    private String sysAclStatus;
    /**
     * sysAclSeq 权限在当前模块下的顺序，由小到大.
     */
    @NotNull(message = "权限在当前模块下的顺序，由小到大  必填", groups = {Add.class, Modify.class})
    private Integer sysAclSeq;

    public static AclReqRedis aclRedis(AclDO aclDO) {
        AclReqRedis aclReq = AclReqRedis.builder().sysAclAction(aclDO.getSysAclAction())
                .sysAclModuleId(aclDO.getSysAclModuleId()).sysAclName(aclDO.getSysAclName())
                .sysAclPermissionType(aclDO.getSysAclPermissionType()).sysAclRouter(aclDO.getSysAclRouter())
                .sysAclAction(aclDO.getSysAclAction()).sysAclName(aclDO.getSysAclName()).sysAclSeq(aclDO.getSysAclSeq())
                .sysAclStatus(aclDO.getSysAclStatus()).sysAclUrl(aclDO.getSysAclUrl()).id(aclDO.getId()).name(aclDO.getName())
                .sysAclType(aclDO.getSysAclType())
                .build();
        return aclReq;
    }
    @Getter
    @Setter
    @ToString
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
//@EqualsAndHashCode(of = {"id"})
    public static class AclReqRedis {
        /**
         * id 权限id.
         */
        private Long id;
        /**
         * sysAclModuleId 权限所在的权限模块id.
         */
        @NotNull(message = "权限所在的权限模块id 必填", groups = {Add.class, Modify.class})
        private Long sysAclModuleId;
        /**
         * sysAclPermissionType 菜单系统类型 1 系统管理 2资产管理.
         */
        @NotNull(message = "菜单系统类型 必填", groups = {Add.class, Modify.class})
        private Long sysAclPermissionType;
        /**
         * name 页面名称(前端控制).
         */
        @NotNull(message = "页面名称(前端控制) 必填", groups = {Add.class, Modify.class})
        private String name;
        /**
         * remark 备注.
         */
        private String remark;
        /**
         * delFlag 删除状态(0-正常，1-删除).
         */
        private String delFlag;
        /**
         * sysAclUrl 请求的url, 可以填正则表达式.
         */
        @NotBlank(message = "请求的url 必填", groups = {Add.class, Modify.class})
        private String sysAclUrl;
        /**
         * sysAclCode 权限码.
         */
        private String sysAclCode;
        /**
         * sysAclIcon 图标class.
         */
        private String sysAclIcon;
        /**
         * sysAclName 权限名称.
         */
        @NotNull(message = "权限名称 必填", groups = {Add.class, Modify.class})
        private String sysAclName;
        /**
         * sysAclType 类型，1：菜单，2：按钮，3：其他.
         */
        @NotBlank(message = "类型，1：菜单，2：按钮，3：其他 必填", groups = {Add.class, Modify.class})
        private String sysAclType;
        /**
         * sysAclUuid 唯一，32位字符串，查询用.
         */
        @NotNull(message = "uuid 必填", groups = {Modify.class})
        private String sysAclUuid;
        /**
         * sysAclAction 按钮动作类型(交给前端处理）.
         */
        @NotBlank(message = "按钮动作类型(交给前端处理） 必填", groups = {Add.class, Modify.class})
        private String sysAclAction;
        /**
         * sysAclRouter 所属页面(交给前端处理).
         */
        @NotBlank(message = "所属页面(交给前端处理)  必填", groups = {Add.class, Modify.class})
        private String sysAclRouter;
        /**
         * sysAclStatus 状态 0启用  1禁用.
         */
        @NotBlank(message = "状态 0启用  1禁用  必填", groups = {Add.class, Modify.class})
        private String sysAclStatus;
        /**
         * sysAclSeq 权限在当前模块下的顺序，由小到大.
         */
        @NotNull(message = "权限在当前模块下的顺序，由小到大  必填", groups = {Add.class, Modify.class})
        private Integer sysAclSeq;
    }
}
